home *** CD-ROM | disk | FTP | other *** search
/ Merciful 2 / Merciful - Disc 2.iso / software / d / dialupv3.06.lha / dialup / dialup.c < prev    next >
C/C++ Source or Header  |  1996-01-30  |  16KB  |  466 lines

  1. #include "dialup.h"
  2.  
  3. static const char version[] = "$VER: Dialup 3.06 (30.1.96)";
  4.  
  5.         BPTR        mystderr    = NULL;
  6. const   UBYTE         *prgname    = NULL;
  7. struct  IOExtSer    *serialIOReq    = NULL;
  8. struct  timerequest    *timereq    = NULL;
  9.         BPTR        repfile        = NULL;
  10.         UBYTE        *rxbuffer    = NULL;
  11.         LONG        arg[A_ALL + 1];
  12.  
  13. struct argspec argtab[] = {
  14.  
  15.     "COMMAND=CMD",            (LONG)"TOGGLE"            ,       /* only TOGGLE    */
  16.     "PHONENUMBER=PN/K/M",        NULL                ,    /* ptr to PN *array* init later    */
  17.     "REDIALDELAY=RDD/K/N",        (LONG)"\0\0\0\xB4"    ,    /* Delay for *same* number 180s    */
  18.     "MODEMCONNECTTIME=MCT/K/N",    (LONG)"\0\0\0\x3D"    ,    /* Time to connect 61s            */
  19.     "RINGS=RGS/K/N",        (LONG)"\0\0\0\x01"    ,    /* AUTOANSWER after 1 RING        */
  20.     "WAITBEFORWUS=WBW/K/N",        (LONG)"\0\0\0\x03"    ,    /* Wait befor sending WUS        */
  21.     "WAKEUPSTRING=WUS/K",        NULL            ,    /* String to sent to get a ogin:*/
  22.     "LOGINPROMPT=LIP/K",        (LONG)"ogin:"        ,    /* prompt of remotesite            */
  23.     "LOGINTIMEOUT=LTO/K/N",        (LONG)"\0\0\0\x03"    ,    /* Time to wait for the loginprompt */
  24.     "LOGINNAME=LIN/K",        NULL            ,    /* Name to answer at A_LIP        */
  25.     "PASSWORDPROMPT=PWP/K",        (LONG)"assword:"    ,    /* prompt for password            */
  26.     "PASSWORD=PW/K",        NULL            ,    /* password                        */
  27.     "SNDLOGINPROMPT=SLIP/K",    (LONG)"ogin:"        ,    /* prompt of remotesite            */
  28.     "SNDLOGINNAME=SLIN/K",        NULL            ,    /* Name to answer at A_LIP        */
  29.     "SNDPASSWORDPROMPT=SPWP/K",    (LONG)"assword:"    ,    /* prompt for snd password        */
  30.     "SNDPASSWORD=SPW/K",        NULL            ,    /* snd password                    */
  31.     "LOGINOK=LOK/K",        (LONG)"Packet mode"    ,    /* answer for correct login        */
  32.     "LOGINOKTIMEOUT=LOT/K/N",    (LONG)"\0\0\0\x03"    ,    /* Time to wait for the LOK Msg    */
  33.     "VERBOSE/S",            NULL            ,    /* debuginig stuff active       */
  34.     "TEST/S",            NULL            ,    /* local analog loopback        */
  35.     "NOSERINIT=NSI/S",        NULL            ,    /* init. of serial line ?        */
  36.     "NODTRIGNORE=NDI/S",        NULL            ,    /* Do not send AT&D0 AT&D2        */
  37.     "REPORTFILE=RPF/K",        NULL            ,    /* where to put report ?        */
  38.     "QUIET/S",            NULL            ,    /* No report of conversation    */
  39.     "STDERR/S",            NULL            ,    /* errormessages to *            */
  40.     "AUTOANSWER=AA/S",        NULL            ,    /* take call after hangup        */
  41.     "NORECONNECT=NRC/S",        NULL            ,    /* do not take call while conn.    */
  42.     "SANADEVICE=SAD/K",            (LONG)"Networks/ppp.device" ,    /* sana device to use            */
  43.     "SANAUNIT=SAU/K/N",        (LONG)"\0\0\0\0"    ,    /* and its unit                    */
  44.     "SANACONFIGFILE=SCF/K",        (LONG)"ppp%d.config"    ,    /* name of the sana config file */
  45.     "CONNECTSTRING=CS/K",        (LONG)"CONNECT?*19200/V42b"     ,    /* part of the std. connectstr. */
  46.     "MODEMSETTINGSCONNECT=MSC/K",   (LONG)"ATZ1"        ,    /* settings for connect            */
  47.     "MODEMSETTINGSHANGUP=MSH/K",    (LONG)"ATZ1"        ,    /* settings after hang up        */
  48.     "MODEMQUERYCMD=MQC/K",        (LONG)"AT&VI2"        ,    /* cmd to query modemstatus        */
  49.     "MODEMREADYCMD=MRC/K",        (LONG)"AT"        ,    /* Modem should answer with OK    */
  50.     "MODEMHANGUPCMD=MHC/K",        (LONG)"ATH0"        ,    /* Modem cmd to drop connection    */
  51.     "MODEMCMDOK=MOK/K",        (LONG)"OK"        ,    /* Answer from modem if cmd OK    */
  52.     "MODEMNOCARRIER=MNC/K",         (LONG)"NO CARRIER"    ,    /* modemanswer if not carrier    */
  53.     "MODEMLINEBUSY=MLB/K",        (LONG)"BUSY"        ,    /* modemanswer if line busy        */
  54.     "MODEMLINEDEAD=MLD/K",        (LONG)"NO DIALTONE"    ,    /* modemanswer if there is no dt*/
  55.     "MODEMRING=MRG/K",        (LONG)"RING"        ,    /* incoming call                */
  56.     "MODEMANYCONNECT=MAC/K",    (LONG)"CONNECT?*\n"    ,    /* modemanswer if any connect    */
  57.     "MODEMAACMD=MAAC/K",        (LONG)"ATS0=%d"        ,    /* Set modem to auto answer        */
  58.     "MODEMOFFLINECMD=MOC/K",    (LONG)"+++"        ,    /* Make modem accept commands    */
  59.     "MODEMONLINECMD=MLC/K",        (LONG)"ATO"        ,    /* Make modem online again        */
  60.     "MODEMTESTCMD=MTC/K",        (LONG)"AT&T1"        ,    /* Make modem loopback            */
  61.     "MODEMTESTOFFCMD=MTO/K",    (LONG)"AT&T0"        ,    /* Make modem stop loopback        */
  62.     "MODEMTOFFHOOKCMD=MOH/K",    (LONG)"ATA"        ,    /* Make modem stop loopback        */
  63.     "GIVEALLSETTINGS=ALL=GAS/S",    NULL                    ,    /* show all defaults            */
  64.                                     NULL                    ,
  65.                                         NULL
  66. };                                                                    /* END of list                    */
  67.  
  68.     UBYTE *PNAdeflt[] = { "ATDS1", NULL };
  69.  
  70.  
  71. int
  72. main(int argc, BYTE **argv)
  73. {
  74.     int result = 20;
  75.  
  76.     /* resurce pointers and resurce openflags: */
  77.     struct MsgPort        *sanaport    = NULL;
  78.     struct IOSana2Req    *sanaIOReq    = NULL;
  79.     struct MsgPort        *serialport    = NULL;
  80.     struct MsgPort        *timeport    = NULL;
  81.     struct RDArgs        *rdclargs    = NULL;
  82.     struct RDArgs        *rdenvargs    = NULL;
  83.     UBYTE            *varbuf        = NULL;
  84.  
  85.     LONG sanaopenerr = TRUE;
  86.     LONG seropenerr = TRUE;
  87.     LONG timeopenerr = TRUE;
  88.  
  89.     /* flags */
  90.     BOOL putOnline        = FALSE;
  91.     BOOL giveusage        = FALSE;
  92.     BOOL giveDefault    = FALSE;
  93.  
  94.     struct SP serpara;    /* serial parameters from of sana device (ppp0.config) */
  95.     UBYTE hostname[30];    /* stringbuffer */
  96.     UBYTE * template;
  97.     LONG argd[A_END + 1];
  98.     UBYTE **pn;            /* array of phonenumbers */
  99.  
  100.     prgname = argv[0];
  101.  
  102.     if (((struct Library *)DOSBase)->lib_Version < 37 )
  103.         return(200);
  104.     if (!unique(serialport))
  105.         return (4);
  106.     if ( ! (varbuf = AllocMem(VARBUFSIZE, MEMF_CLEAR|MEMF_PUBLIC) ) || ! (template = AllocMem(TEMPLATESIZE, MEMF_CLEAR|MEMF_PUBLIC) ) )
  107.         CUP("Error allocating memory", 51);
  108.     giveDefault = (argc > 1 && ABBREV(argv[1], "DE") );
  109.  
  110.     initDefaultsAndTemplate(template);
  111.     if ( strlen(template) > TEMPLATESIZE - 50 )
  112.         CUP("Template buffer to small", 52);
  113.  
  114.     pn = PNAdeflt;
  115.  
  116.     /* check environment variable: */
  117.     if ( GetVar( "DIALUP",  varbuf,  VARBUFSIZE, 0 ) != -1 )
  118.     {            /* parse env:dialup */
  119.         if ( ! ( rdenvargs = AllocDosObject( DOS_RDARGS, NULL) ) )
  120.             CUP("Can't allocate DosObject for reading args", 50);
  121.  
  122.         rdenvargs->RDA_Source.CS_Buffer = varbuf;
  123.         rdenvargs->RDA_Source.CS_Length = VARBUFSIZE;
  124.         rdenvargs->RDA_Source.CS_CurChr = 0;
  125.  
  126.         /* ReadArgs() requires that the line be null-terminated or funny things happen. */
  127.         strcat(varbuf, "\n");
  128.         if( !ReadArgs( template, arg, rdenvargs ) )
  129.         {
  130.             Fault(IoErr(), prgname, varbuf, VARBUFSIZE);
  131.             CUP1("Error parsing environment variable 'DIALUP':\n%s", varbuf, 20);
  132.         }
  133.         if ( arg[A_PN] )
  134.                    pn = (UBYTE **)arg[A_PN]; /* save pns for next call to ReadArgs() */
  135.     }
  136.  
  137.     adjustdefs();
  138.  
  139.     if ( giveDefault )
  140.         if ( !initDefaultsTemplate(template, argd) )
  141.             CUP("MAXARGNAMELEN to small!", 53);
  142.  
  143.             /* parse for command line for paramters or defaultkeywords: */
  144.     if ( ! ( rdclargs = ReadArgs(template, giveDefault ? argd : arg, NULL ) ) )
  145.     {
  146.         Fault(IoErr(), prgname, varbuf, VARBUFSIZE);
  147.         CUP1("Error parsing command line.\n%s", varbuf, 20);
  148.     };
  149.     if ( template )    { FreeMem( template, TEMPLATESIZE );
  150.         template = NULL; };
  151.  
  152.     adjustdefs();
  153.  
  154.     if ( !arg[A_PN]  )
  155.         arg[A_PN] = (LONG)pn; /* corrects a Bug in Readargs(): /M arrays ignore preset defaults  :-( */
  156.     if ( !arg[A_LIN] )
  157.         if ( GetVar( "HOSTNAME", hostname, 30, 0 ) != -1 )
  158.             arg[A_LIN] = (LONG)hostname;
  159.     if ( giveDefault )
  160.     {
  161.         showdefaults(argd);
  162.         result = 0;
  163.     }
  164.     else
  165.     {    /* now one indent level is missing! (I'm lazy *and* don't like goto's :) */
  166.         if ( arg[A_STE] || IsInteractive( Input() ) )
  167.             if ( !( mystderr = Open("*", MODE_OLDFILE) ) )
  168.                 CUP("Sorry for the requester,\nbut: Unable to open '*' (stderr)!\n", 99);
  169.  
  170.         if ( !arg[A_LIN] && strcmp( (UBYTE *) arg[A_LIP], "" ) )
  171.             CUP(" Please specify paramter LOGINNAME=LIN\n or setenv 'HOSTNAME' instead! (To skip \n login chat specify LOGINPROMPT=LIP \"\".) ", 35)
  172.         if ( !arg[A_PW] && strcmp( (UBYTE *)arg[A_PWP], "" ) && strcmp( (UBYTE *)arg[A_LIP], "" ) )
  173.             CUP(" Please specify paramter PASSWORD=PW!\n (To skip password chat specify\n PASSWORDPROMPT=PWP \"\") ", 36)
  174.  
  175.                 /* where to put the report of serial communication and sana status */
  176.         if ( ! arg[A_RPF] )
  177.         {
  178.             if ( !arg[A_QUIET] )
  179.                 repfile = Output();
  180.         }
  181.         else
  182.         if ( ! ( repfile = Open((UBYTE *)arg[A_RPF], MODE_NEWFILE ) ) )
  183.             CUP1("Unable to create reportfile '%s'", arg[A_RPF], 21);
  184.  
  185.         if ( ! ReadConfig( (UBYTE *)arg[A_SCF], *(LONG *)arg[A_SAU], &serpara) )
  186.             CUP("Error reading sana configuration file!", 22);
  187.         if ( ( arg[A_AA] || !arg[A_NRC] ) && serpara.listen2CD )
  188.             msg("\
  189.  Warning: If you don't remove the 'CD' paramter from\n\
  190.           the sana configuration file, you will'\n\
  191.           have to manually 'online' the sana device \n\
  192.           on incomming calls.\n\
  193.           (To avoid this warning use NORECONNECT or NRC)",
  194.             *(LONG *)arg[A_SAU]);
  195.  
  196.                 /* open ppp.device */
  197.         if ( ! ( sanaport = CreateMsgPort() ) )
  198.             CUP("Unable to create message port for sana device.", 23);
  199.         if ( ! ( sanaIOReq = CreateIORequest(sanaport, sizeof(*sanaIOReq) ) ) )
  200.             CUP ("Unable to create IORequest for sanal line.", 24);
  201.         if ( sanaopenerr = OpenDevice((UBYTE *)arg[A_SAD], *(LONG *)arg[A_SAU], (struct IORequest *)sanaIOReq, 0L))
  202.             CUP1("Unable to open sana device '%s'.",arg[A_SAD], 25);
  203.  
  204.             /************************************************/
  205.             /* Sana ONLINE                                    */
  206.             /************************************************/
  207.         if ( ABBREV((UBYTE *)arg[A_CMD], "ON" ) )
  208.         {
  209.             putOnline = TRUE;
  210.             result = 0;
  211.         }
  212.             /**********************************************/
  213.             /* Sana OFFLINE                                  */
  214.             /**********************************************/
  215.         else
  216.         if ( ABBREV((UBYTE *)arg[A_CMD], "OF" ) )
  217.         {
  218.             sanaIOReq->ios2_Req.io_Command = S2_OFFLINE;
  219.             if ( DoIO( (struct IORequest *)sanaIOReq) )
  220.                 CUP("Error in making sana device offline.", 26);
  221.             if ( repfile )
  222.                 Write(Output(), WS("Sana offline\n"));
  223.             putOnline = FALSE;
  224.             result = 0;
  225.         }
  226.         else
  227.         {
  228.             /* now another indent level more missing! (I'm lazy *and* don't like goto's :) */
  229.             /* get receivebuffer */
  230.             if ( ! ( rxbuffer = AllocMem(RXBUFSIZE, 0) ) )
  231.                 CUP("Unable get memory for receive buffer.", 27);
  232.  
  233.             /* open timer device */
  234.             if ( ! ( timeport = CreateMsgPort() ) )
  235.                 CUP("Unable to create message port for timer device.", 28);
  236.             if ( ! ( timereq = (struct timerequest *)CreateIORequest( timeport, sizeof( struct timerequest ) ) ) )
  237.                 CUP ("Unable to create IORequest for timer device.", 29);
  238.             if ( timeopenerr = OpenDevice(TIMERNAME, UNIT_VBLANK, (struct IORequest *)timereq, 0L) )
  239.                 CUP("Timer device did not open.", 30);
  240.  
  241.             /* open serial device */
  242.             if ( ! ( serialport = CreateMsgPort() ) )
  243.                 CUP("Unable to create message port for serial line.", 31);
  244.             serialport->mp_Node.ln_Name = SERPORTNAME;
  245.             serialport->mp_Node.ln_Pri    = -1;
  246.             AddPort(serialport);
  247.             if ( ! ( serialIOReq = (struct IOExtSer *) CreateIORequest( serialport, sizeof(struct IOExtSer) ) ) )
  248.             CUP ("Unable to create IORequest for serial line.", 32);
  249.             serialIOReq->io_SerFlags = 0;
  250.             if ( seropenerr = OpenDevice(serpara.serDevName, serpara.serUnit, (struct IORequest *)serialIOReq, 0) )
  251.             {
  252.                 sanaIOReq->ios2_Req.io_Command = S2_OFFLINE;
  253.                 if ( repfile )
  254.                     Write(Output(), WS("Sana offline\n"));
  255.                 if ( DoIO( (struct IORequest *)sanaIOReq) )
  256.                     CUP("Error in sana offline for opening serial device.", 33);
  257.                 if ( seropenerr = OpenDevice(serpara.serDevName, serpara.serUnit, (struct IORequest *)serialIOReq, 0) )
  258.                     CUP("Serial device did not open (even with slip offline!).", 34 );
  259.                 putOnline = TRUE;
  260.             }
  261.  
  262.             if ( !initSerialLine(&serpara) )
  263.                 CUP("Error initalizing serial line", 39 )
  264.  
  265.             result = 10;    /* so far, so good ..  No fatal errors anymore */
  266.  
  267.             /**********************************************/
  268.             /* TAKE                                          */
  269.             /**********************************************/
  270.             if ( ABBREV((UBYTE *)arg[A_CMD], "TA" ) )
  271.             {
  272.                 if ( carrier() )
  273.                     putOnline = TRUE;
  274.                 else
  275.                 {
  276.                     if ( (result = take( varbuf ) < 10 ) )
  277.                         putOnline = TRUE;
  278.                     else /* something went wrong */
  279.                     {    /* hangup if we are running without user */
  280.                         if ( ! IsInteractive( Input() ) )
  281.                             if ( ! hangup(varbuf) )
  282.                                 hangup(varbuf);
  283.                         if ( ! arg[A_QUIET] )
  284.                             msg("Failed to take call!");
  285.                     }
  286.                 }
  287.             }
  288.             /**********************************************/
  289.             /* CONNECT, TOGGLE                              */
  290.             /**********************************************/
  291.             else
  292.             if ( ( ABBREV((UBYTE *)arg[A_CMD], "TO" ) && !carrier() ) || ABBREV((UBYTE *)arg[A_CMD], "CO" ) )
  293.             {
  294.                 if ( carrier() )
  295.                 {
  296.                     if ( !arg[A_QUIET] )
  297.                         msg("Modem is already online!\n(carrier detected)");
  298.                     result = 5;
  299.                 }
  300.                 else
  301.                 {
  302.                     if ( connect(varbuf) )
  303.                     {
  304.                         putOnline = TRUE;
  305.                         result = 1;
  306.                     }
  307.                     else /* something went wrong */
  308.                     {
  309.                         if ( ! IsInteractive( Input() ) )
  310.                             if ( ! hangup(varbuf) )
  311.                                 hangup(varbuf);
  312.                         if ( ! arg[A_QUIET] )
  313.                             msg("Failed to connect!");
  314.                     }
  315.                 }
  316.             }
  317.             /**********************************************/
  318.             /* HANGUP and TOGGLE                          */
  319.             /**********************************************/
  320.             else
  321.             if ( ( ABBREV((UBYTE *)arg[A_CMD], "TO" ) && carrier() ) || ( ABBREV((UBYTE *)arg[A_CMD], "HA" ) ) )
  322.             {
  323.                 if ( hangup(varbuf) )
  324.                     result = 0; 
  325.                 if ( !arg[A_QUIET] && ( result >= 10 || carrier() ) )
  326.                     msg("Failed to disconnect!");
  327.                 else
  328.                 {
  329.                     if ( arg[A_AA] )
  330.                         putOnline = TRUE;    /* put online after hangup for taking incomming calls */
  331.                     else
  332.                         putOnline = FALSE;    /* put offline after hangup */
  333.                 }
  334.             }
  335.             /**********************************************/
  336.             /* QUERY modem                                  */
  337.             /**********************************************/
  338.             else
  339.             if ( ABBREV((UBYTE *)arg[A_CMD], "QU" ) )
  340.             {
  341.                 if ( query(varbuf) )
  342.                     result = 2;
  343.             }
  344.             /**********************************************/
  345.             /* CARRIER DETECT and make online if present  */
  346.             /**********************************************/
  347.             else
  348.             if ( ABBREV((UBYTE *)arg[A_CMD], "CD" ) || ABBREV((UBYTE *)arg[A_CMD], "CARRIERDETECT" ) )
  349.             {
  350.                 if ( carrier() )
  351.                 {
  352.                     putOnline = TRUE;
  353.                     result = 5;
  354.                 }
  355.                 else
  356.                 {
  357.                     putOnline = FALSE;
  358.                     result = 0;
  359.                 }
  360.             }
  361.             /**********************************************/
  362.             /* CHECK for carrier                          */
  363.             /**********************************************/
  364.             else
  365.             if ( ABBREV((UBYTE *)arg[A_CMD], "CH" ) )
  366.             {
  367.                 result = carrier() ? 5 : 0;
  368.             }
  369.             /*********/
  370.             /* Usage */
  371.             /*********/
  372.             else
  373.                 giveusage = TRUE;
  374.  
  375.         };
  376.     };
  377.  
  378. cleanup:
  379.  
  380.     if ( ! seropenerr )
  381.     {
  382.         if ( result >= 10 )
  383.             DeleteVar( "SLIPCARRIER", GVF_GLOBAL_ONLY );
  384.         else
  385.             SetVar( "SLIPCARRIER", carrier() ? "ON" : "OFF" , -1, GVF_GLOBAL_ONLY );
  386.  
  387.         CloseDevice((struct IORequest*)serialIOReq);
  388.     }
  389.  
  390.     if ( ! sanaopenerr )
  391.     {
  392.         if ( putOnline )
  393.         {
  394.             sanaIOReq->ios2_Req.io_Command = S2_ONLINE;
  395.             if ( DoIO((struct IORequest *)sanaIOReq) )
  396.                 result = 10;
  397.             else
  398.             if ( repfile )
  399.                 Write(Output(), WS("Sana online\n"));
  400.         }
  401.         CloseDevice((struct IORequest*)sanaIOReq);
  402.     };
  403.  
  404.     if ( ! timeopenerr)
  405.     {
  406.         if ( ! CheckIO( (struct IORequest *)timereq ) )
  407.             AbortIO( (struct IORequest *)timereq );
  408.         CloseDevice( (struct IORequest *)timereq );
  409.     }
  410.  
  411.     if ( serialport )
  412.     {
  413.         if ( serialport->mp_Node.ln_Name )
  414.             RemPort(serialport);
  415.         DeleteMsgPort(serialport);
  416.     };
  417.     if ( serialIOReq )    DeleteIORequest((struct IORequest*)serialIOReq);
  418.     if ( sanaport )        DeleteMsgPort(sanaport);
  419.     if ( sanaIOReq )    DeleteIORequest((struct IORequest*)sanaIOReq);
  420.     if ( timeport )        DeleteMsgPort( timeport );
  421.     if ( timereq )        DeleteIORequest( timereq );
  422.  
  423.     /* usage after closing serial device and (maybe) online of sana: */
  424.      if ( giveusage )    msg("%s\n\n\
  425. Unknown command '%s'. Valid Commands are:\n\n\
  426. COnnect, HAngup, TOggle, TAke, QUery,\n\
  427. ONline, OFfline, CarrierDetect and CHeck.\n\
  428. The default COMMAND is TOGGLE (CONNECT/HANGUP).\n\
  429. \n\
  430. To get the parameter template use '%s ?'.\n\
  431. \n\
  432. TEST does a modem internal loopback test and no real connect.\n\
  433. RINGS does only take effect after HANGUP with AUTOANSWER.\n\
  434. Use COnnect QUIET before every netappli. to ensure connection.\n\
  435. Add '%s CD' to user-startup to online after reboot\n\n\
  436. To get the paramter defaults use %s DEfault <parameter>|ALL",
  437. &version[6], (UBYTE *)arg[A_CMD], prgname, prgname, prgname);
  438.  
  439.     if ( rxbuffer )
  440.         FreeMem( rxbuffer, RXBUFSIZE );
  441.     if ( arg[A_RPF] && repfile )
  442.         Close( repfile );
  443.     if ( rdclargs )
  444.         FreeArgs( rdclargs );
  445.      if ( rdenvargs )
  446.     {
  447.         FreeArgs( rdenvargs );
  448.         FreeDosObject(DOS_RDARGS, rdenvargs);
  449.     };
  450.     if ( varbuf )
  451.         FreeMem( varbuf, VARBUFSIZE );
  452.     if ( template )
  453.         FreeMem( template, TEMPLATESIZE );
  454.     if ( mystderr )
  455.         Close(mystderr);
  456.     return( result );
  457. }
  458.  
  459. void
  460. adjustdefs()
  461. {
  462.     if ( arg[A_SCF] == argtab[A_SCF].deflt && ( strstr( (UBYTE *)arg[A_SAD], "ppp" ) || strstr( (UBYTE *)arg[A_SAD], "PPP" ) ) )
  463.         arg[A_SCF] = (LONG)"ppp%d.config";
  464.     if ( arg[A_VERBOSE] && !arg[A_RPF] ) arg[A_RPF] = (LONG)"CON:50/50/400/200/Dialup(VEROSE)/CLOSE/INACTIVE/WAIT";
  465. }
  466.